package leetcom.com234;

import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class EX5715 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = scanner.nextInt();
        }
        int res = 0;
        for (int i = 0; i < n ; i++) {
            for (int j = i+1; j < n; j++) {
                res+=(a[i]|a[j]);
            }
            res+=a[i];
        }
        System.out.println(res);
    }
}
